package com.webservice.impl;

import com.dao.*;
import com.domain.*;
import com.tool.Until;
import com.webservice.LoginWebservice;
import org.springframework.beans.factory.annotation.Autowired;

import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import java.util.List;

@WebService(targetNamespace = "http://39.98.59.6/mmms_test/ws/login")
public class LoginWebserviceImpl implements LoginWebservice {

    @Autowired
   private UserDao userDao;

    @WebResult(name="User")
    @Override
    public User login(@WebParam(name = "tel") String tel, @WebParam(name = "password") String password) {
        List<User> login = userDao.login(tel, password);
        if (login != null){
            for (User user:login){
                if (user.getAccount_state_id() == 2 || user.getAccount_state_id() == 1){
                    user = Until.findById(user.getId());
                    return user;
                }
            }
        }
        return new User();
    }





}
